﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Accounting.Common.Helpers;

namespace Accounting.Controllers
{
    public class BaseController : Controller
    {
        protected override void ExecuteCore()
        {
            string cultureName = null;

            HttpCookie cultureCookie = Request.Cookies["_culture"];

            if (cultureCookie != null)
                cultureName = cultureCookie.Value;
            else
                // obtain it from HTTP header AcceptLanguages
                cultureName = Request.UserLanguages[0];

            // Validate culture name
            //cultureName = CultureHelper.GetImplementedCulture(cultureName);
            CultureHelper.SetCulture(cultureName);

            base.ExecuteCore();
        }

    }
}
